<?php

class Gmapsprofile_Plugin_Core extends Core_Model_Abstract
{

  public function onUserUpdateAfter($event)
  {
    $payload = $event->getPayload();

    if( !($payload instanceof User_Model_User) ) {
      return;
    }

	Engine_Api::_()->getDbtable('markers', 'gmapsprofile')->delete(array(
      'user_id = ?' => $payload->getIdentity(),
    ));
	Engine_Api::_()->gmapsprofile()->geocoding($payload->getIdentity());
  }

  public function onUserCreateAfter($event)
  {
    $payload = $event->getPayload();

    if( !($payload instanceof User_Model_User) ) {
      return;
    }
	Engine_Api::_()->getDbtable('markers', 'gmapsprofile')->delete(array(
      'user_id = ?' => $payload->getIdentity(),
    ));
	Engine_Api::_()->gmapsprofile()->geocoding($payload->getIdentity());
  }
}